import 'package:cbec_app/components/base/base_interactive.dart';
import 'package:cbec_app/components/base/base_page.dart';
import 'package:cbec_app/components/common/common_style.dart';
import 'package:cbec_app/components/base/base_nav_bar.dart';
import 'package:cbec_app/pages/login/controller/login_ctr.dart';
import 'package:cbec_app/utils/Tools.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';

//修改密码
class FixPassword extends GetView<LoginController> {
  FixPassword({super.key});

  @override
  Widget build(BuildContext context) {
    return GetBuilder<LoginController>(
      builder: (controller) {
        return BasePage(
          title: "忘记密码",
          iconType: IconType.back,
          bodyColor: Colors.white,
          isShowPadding: true,
          children: [
            //设置新密码
            Container(
                margin: EdgeInsets.only(top: 20.w, left: 18.w, right: 18.w),
                child: Text("账号/手机号",
                    style: TextStyle(
                        fontSize: 14,
                        fontWeight: FontWeight.w500,
                        color: Tools.fromHex("#3D3D3D")))),
            Container(
              margin: EdgeInsets.only(left: 18.w, right: 18.w),
              padding: EdgeInsets.only(bottom: 5.w),
              decoration: BoxDecoration(
                border: Border(
                  bottom: BorderSide(
                    color: Tools.fromHex("#D7D7D7"),
                    width: 1.0,
                  ),
                ),
              ),
              child: Row(
                mainAxisAlignment: MainAxisAlignment.spaceBetween,
                children: [
                  Row(
                    mainAxisAlignment: MainAxisAlignment.start,
                    children: [
                      SizedBox(
                        width: 200.w,
                        child: TextFormField(
                          decoration: descript("请输入账号/手机号"),
                          controller: controller.phoneCtr,
                          onChanged: (value) {
                            controller.onInputPhone(value);
                          },
                        ),
                      )
                    ],
                  ),
                  SizedBox(
                    child: BaseInteractive(
                      onClick: (){
                        controller.phoneNumber='';
                        controller.phoneCtr.text = '';
                      },
                      childWidget: Icon(
                        Icons.close,
                        size: 18,
                        color: Tools.fromHex("#999999"),
                      ),
                    ),
                  ),
                ],
              ),
            ),
            
             //下面的验证码输入框及发送验证码的按钮
             Container(
                margin: EdgeInsets.only(top: 20.w, left: 18.w, right: 18.w),
                child: Text("验证码",
                    style: TextStyle(
                        fontSize: 14,
                        fontWeight: FontWeight.w500,
                        color: Tools.fromHex("#3D3D3D")))),
            Container(
              decoration: BoxDecoration(
                border: Border(
                  bottom: BorderSide(
                    color: Tools.fromHex("#D7D7D7"),
                    width: 1.0,
                  ),
                ),
              ),
              // height: 40.h,
              margin: EdgeInsets.only(left: 18.w, right: 18.w),
              child: Row(
                mainAxisAlignment: MainAxisAlignment.spaceBetween,
                children: [
                  Container(
                    padding: EdgeInsets.only(bottom: 5.w),
                    width: 200.w,
                    child: TextFormField(
                      decoration: descript("请输入手机验证码"),
                      onChanged: (value) {
                        controller.onInputResetCode(value);
                      },
                      // textAlign: TextAlign.center,
                    ),
                  ),
                  SizedBox(
                    child: BaseInteractive(
                      onClick: (){
                        controller.getResetCode();
                      },
                      childWidget: Container(
                        padding: EdgeInsets.only(left: 10.w),
                        decoration: BoxDecoration(
                          border: Border(
                            left: BorderSide(
                              color: Tools.fromHex("#D7D7D7"),
                              width: 1.0,
                            ),
                          ),
                        ),
                        child: Text(controller.countdownTxt,style: setTextStyle(14, FontWeight.w500, controller.buttonColor)),
                      ),
                    ),
                  )
                  // SizedBox(
                  //   child: ElevatedButton(
                  //       style: ButtonStyle(
                  //         backgroundColor: MaterialStateProperty.all(
                  //             controller.buttonColor),
                  //         shape:
                  //             MaterialStateProperty.all<RoundedRectangleBorder>(
                  //           RoundedRectangleBorder(
                  //             borderRadius:
                  //                 BorderRadius.circular(15.0), //设置圆角半径
                  //           ),
                  //         ),
                  //       ),
                  //       onPressed: (){
                  //         controller.getResetCode();
                  //       },
                  //       child: const Text(
                  //         "获取验证码",
                  //         style: TextStyle(
                  //             fontSize: 14.0,
                  //             fontWeight: FontWeight.w300,
                  //             color: Colors.white),
                  //       )),
                  // )
                ],
              ),
            ),

            //设置新密码
            Container(
                margin: EdgeInsets.only(top: 20.w, left: 18.w, right: 18.w),
                child: Text("请设置新的登录密码",
                    style: TextStyle(
                        fontSize: 14,
                        fontWeight: FontWeight.w500,
                        color: Tools.fromHex("#3D3D3D")))),
            Container(
              margin: EdgeInsets.only(left: 18.w, right: 18.w),
              padding: EdgeInsets.only(bottom: 5.w),
              decoration: BoxDecoration(
                border: Border(
                  bottom: BorderSide(
                    color: Tools.fromHex("#D7D7D7"),
                    width: 1.0,
                  ),
                ),
              ),
              child: TextFormField(
                decoration: descript("8-12位，不能与旧密码相同"),
                onChanged: (value) {
                  controller.onInputPassword(value);
                },
              ),
            ),
            Container(
                margin: EdgeInsets.only(top: 20.w, left: 18.w, right: 18.w),
                child: Text("确认密码",
                    style: TextStyle(
                        fontSize: 14,
                        fontWeight: FontWeight.w500,
                        color: Tools.fromHex("#3D3D3D")))),
            Container(
              margin: EdgeInsets.only(left: 18.w, right: 18.w),
              padding: EdgeInsets.only(bottom: 5.w),
              decoration: BoxDecoration(
                border: Border(
                  bottom: BorderSide(
                    color: Tools.fromHex("#D7D7D7"),
                    width: 1.0,
                  ),
                ),
              ),
              child: TextFormField(
                decoration: descript("需要与新设置的密码相同"),
                onChanged: (value) {
                  controller.onInputConfirmPassword(value);
                },
              ),
            ),

           
            //-----下面是按钮------
            buttons()
          ],
        );
      },
    );
  }

  /**
       * 按钮
       */
  Widget buttons() => Container(
        margin: EdgeInsets.only(top: 40.w, left: 18.w, right: 18.w),
        width: double.infinity,
        color: Colors.white,
        // padding: EdgeInsets.fromLTRB(18.w, 18.w, 18.w, 18.w),
        child: ElevatedButton(
            style: ButtonStyle(
              backgroundColor:
                  MaterialStateProperty.all(controller.buttonColor),
            ),
            onPressed: (){
              controller.completeResetPassword();
            },
            child: Text(
              "完成",
              //loginCtr.btnTxt.value,
              style: const TextStyle(
                  fontSize: 14.0,
                  fontWeight: FontWeight.w500,
                  color: Colors.white),
            )),
      );
}
